package com.ouss.tabs;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;

public class TabFragment extends Fragment {
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if (container == null) {
			// We have different layouts, and in one of them this
			// fragment's containing frame doesn't exist. The fragment
			// may still be created from its saved state, but there is
			// no reason to try to create its view hierarchy because it
			// won't be displayed. Note this is not needed -- we could
			// just run the code below, where we would create and return
			// the view hierarchy; it would just never be used.
			return null;
		}
		
		String url = getArguments().getString("url");
		boolean resultat = getArguments().getBoolean("resultat");
		boolean promogoal = getArguments().getBoolean("promogoal");
		
		
		LinearLayout current =  (LinearLayout) inflater.inflate(R.layout.tabs_fragment1_layout,
				container, false);
		final ListView listview = (ListView) current.findViewById(R.id.listViewData1);
		/*final Context context = inflater.getContext();
		Handler mHandler = new Handler() { 
            @Override public void handleMessage(Message msg) { 
            	List list=(List)msg.obj;
            	listview.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list));
            	//Toast.makeText(context, "List : "+list.get(0), Toast.LENGTH_SHORT).show();
            }
        };*/
        
		parseSite parse = new parseSite();
		parse.setResultat(resultat);
		parse.setPromogoal(promogoal);
		parse.setListView(listview);
		//parse.setHandler(mHandler);
		parse.setContext(inflater.getContext());
		parse.setPd(ProgressDialog.show(inflater.getContext(),
				"Working...", "request to server", true, false));
		parse.execute(url);
        
		return current;
	}
}
